<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%
	String path = request.getContextPath();
%>
<html>
	<head>
		<title>不良因素评估</title>
		<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/btn_class.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/extjs/style.css" />
<script type="text/javascript"
	src="<%=path%>/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=path%>/extjs/ext-all.js"></script>
<script type="text/javascript" src="<%=path%>/extjs/source/locale/ext-lang-zh_CN.js"></script>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	
</head>

<body >
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = "<%=path%>/extjs/resources/images/default/s.gif";
Ext.onReady(function(){
	
	//*******************************************************重写RadioGroup****************************************	 
  	Ext.override(Ext.form.RadioGroup, {     
	    getValue: function(){     
	        var v;     
	        if (this.rendered) {     
	            this.items.each(function(item){     
	                if (!item.getValue())      
	                    return true;     
	                v = item.getRawValue();     
	                return false;     
	            });     
	        }     
	        else {     
	            for (var k in this.items) {     
	                if (this.items[k].checked) {     
	                    v = this.items[k].inputValue;     
	                    break;     
	                }     
	            }     
	        }     
	        return v;     
	    },     
	    setValue: function(v){     
	        if (this.rendered)      
	            this.items.each(function(item){     
	                item.setValue(item.getRawValue() == v);     
	            });     
	        else {     
	            for (var k in this.items) {     
	                this.items[k].checked = this.items[k].inputValue == v;     
	            }     
	        }     
	    }     
	}); 
	
	var Jthtwb = Ext.data.Record.create([ {
		name : 'fbihid',
		mapping : 'fbihid',
		type : 'string'
	}, {
		name : 'fch',
		mapping : 'fch',
		type : 'string'
	}, {
		name : 'fname',
		mapping : 'fname',
		type : 'string'
	}, {
		name : 'fsex',
		mapping : 'fsex',
		type : 'string'
	}, {
		name : 'fage',
		mapping : 'fage',
		type : 'string'
	}, {
		name : 'fzdbm',
		mapping : 'fzdbm',
		type : 'string'
	}, {
		name : 'fzd_desc',
		mapping : 'fzd_desc',
		type : 'string'
	}, {
		name : 'foffi',
		mapping : 'foffi',
		type : 'string'
	}, {
		name : 'foffi_desc',
		mapping : 'foffi_desc',
		type : 'string'
	}, {
		name : 'fzdbm',
		mapping : 'fzdbm',
		type : 'string'
	}, {
		name : 'fwxcd',
		mapping : 'fwxcd',
		type : 'string'
	}, {
		name : 'fstate',
		mapping : 'fstate',
		type : 'string'
	}, {
		name : 'flastDate',
		mapping : 'flastDate',
		type : 'string'
	}, {
		name : 'fnextDate',
		mapping : 'fnextDate',
		type : 'string'
	}, {
		name : 'fid_yfcs',
		mapping : 'fid_yfcs',
		type : 'string'
	}, {
		name : 'fdesc_yfcs',
		mapping : 'fdesc_yfcs',
		type : 'string'
	}, {
		name : 'fid_pgys',
		mapping : 'fid_pgys',
		type : 'string'
	}, {
		name : 'fdesc_pgys',
		mapping : 'fdesc_pgys',
		type : 'string'
	}, {
		name : 'fname_pgys',
		mapping : 'fname_pgys',
		type : 'string'
	}, {
		name : 'fscore_pgys',
		mapping : 'fscore_pgys',
		type : 'string'
	}, {
		name : 'fscore',
		mapping : 'fscore',
		type : 'string'
	}  ]);

	var ds = new Ext.data.Store({
		reader : new Ext.data.JsonReader({
			totalProperty : 'totalProperty',
			root : 'root'
		}, Jthtwb),
		idProperty : 'threadid',
		remoteSort : true,
		url : 'blPatient!queryPatientList.do'

	});

	ds.load({
		params : {
			"start" : 0,
			"fstate" : '',
			"foffi" : '',
			"fwxcd" : '',
			"fname" : '',
			"fbihid" : ''
		}
	});


	//定义勾选框，不需要可不必定义
	var sm = new Ext.grid.CheckboxSelectionModel({
		singleSelect : true
	});
	//危险程度信息
	var wxcd_store = new Ext.data.SimpleStore( {
						fields : [ 'wxcd_id', 'wxcd_desc' ],
						data : [ [ 1, '低度' ], [ 2, '中度' ], [ 3, '高度' ] ]});
	//状态信息
	var state_store = new Ext.data.SimpleStore( {
						fields : [ 'state_id', 'state_desc' ],
						data : [ [ 1, '已评估' ], [ 2, '未评估' ], [ 3, '停止评估' ] ]});

	//定义列
	var colM = new Ext.grid.ColumnModel([ sm, new Ext.grid.RowNumberer(),//增加自动编号，不需要可不必定义
	    {
			header : '姓名',
			dataIndex : 'fname',
			width : 70,
			sortable : false
		},{
			header : '危险程度',
			dataIndex : 'fwxcd',
			width : 70,
			renderer : function(value, cellmeta, record){
            	//获取当前id="combo_process"的comboBox选择的值
				var index = wxcd_store.find(Ext.getCmp('wxcd_combox').valueField, value);
				var record = wxcd_store.getAt(index);
				var displayText = "";
				// 如果下拉列表没有被选择，那么record也就不存在，这时候，返回传进来的value，
				// 而这个value就是grid的deal_with_name列的value，所以直接返回
				if (record == null) {
					//返回默认值，这是与网上其他解决办法不同的。这个方法才是正确的。我研究了很久才发现。
					displayText = value;
				} else {
					displayText = record.data.wxcd_desc;//获取record中的数据集中的process_name字段的值
				}
				return displayText;
            },
            editor: new Ext.form.ComboBox({
	                //typeAhead: true,
	                mode : 'local',
                    hiddenName : 'fwxcd',
					hiddenValue : 'fwxcd',
					id : 'wxcd_combox',
					valueField : 'wxcd_id',
					displayField : 'wxcd_desc',
					triggerAction : 'all',
              		// transform:'light',
               		store : wxcd_store
	               //listClass: 'x-combo-list-small'
	            })
		},{
			header : '状态',
			dataIndex : 'fstate',
			width : 70,
			renderer : function(value, cellmeta, record){
            	//获取当前id="combo_process"的comboBox选择的值
				var index = state_store.find(Ext.getCmp('state_combox').valueField, value);
				var record = state_store.getAt(index);
				var displayText = "";
				// 如果下拉列表没有被选择，那么record也就不存在，这时候，返回传进来的value，
				// 而这个value就是grid的deal_with_name列的value，所以直接返回
				if (record == null) {
					//返回默认值，这是与网上其他解决办法不同的。这个方法才是正确的。我研究了很久才发现。
					displayText = value;
				} else {
					displayText = record.data.state_desc;//获取record中的数据集中的process_name字段的值
				}
				return displayText;
            },
            editor: new Ext.form.ComboBox({
	                //typeAhead: true,
	                mode : 'local',
                    hiddenName : 'fstate',
					hiddenValue : 'fstate',
					id : 'state_combox',
					valueField : 'state_id',
					displayField : 'state_desc',
					triggerAction : 'all',
              		// transform:'light',
               		store : state_store
	               //listClass: 'x-combo-list-small'
	            })
		},{
			header : '诊断',
			dataIndex : 'fzd_desc',
			width : 150,
			sortable : false
		}, {
			header : '上次评估日期',
			dataIndex : 'flastDate',
			width : 100,
			renderer : function(value) {
					if (value == "null") {
						return "";
					} else {
						return value;
					}
				}
		}, {
			header : '下次评估日期',
			dataIndex : 'fnextDate',
			width : 100,
			renderer : function(value) {
					if (value == "null") {
						return "";
					} else {
						return value;
					}
				}
		} ]);


  	var btn_search_patient = new Ext.Button({
		text : '查询',
		id : 'search_id',
		iconCls : 'sy-search',
		handler : function() {
			ds.removeAll();
			ds.on('beforeload', function(store) {
				this.baseParams = {
						"fstate" : radiogroup.getValue(),
						"foffi" : Ext.get("foffi_id").dom.value,
						"fwxcd" : Ext.get("fwxcd_id").dom.value,
						"fname" : Ext.get("fname_id").dom.value,
						"fbihid" : Ext.get("fbihid_id").dom.value
					};
			});
			ds.load({
				params : {
					"start" : 0
				}
			});
		}
	});
	
	//查询条件line1
  	var firstTbar = new Ext.Toolbar({
		items:[ '姓名:', {	
			id : 'fname_id',
			name : 'fname',
			width : 70,
			xtype : "textfield",
			enableKeyEvents : true, 
			scope: this,
				listeners: {
			    	'keydown': {key: [10,13], fn: function(o, evt) {
            		var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
							if (keyCode == 13) {
    							Ext.getCmp("fbihid_id").focus(false,100);
					       }
                 } , scope: this
                 } 
           }
		}, '-', '住院号:', {	
			id : 'fbihid_id',
			name : 'fbihid',
			width : 70,
			xtype : "textfield",
			enableKeyEvents : true, 
			scope: this,
				listeners: {
			    	'keydown': {key: [10,13], fn: function(o, evt) {
            		var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
							if (keyCode == 13) {
    							Ext.getCmp("search_id").focus(false,100);
					       }
                 } , scope: this
                 } 
           }
		}, '-', btn_search_patient ] 
		});
	
  
	//状态radio
	var radiogroup = new Ext.form.RadioGroup({
                       id:'fstate_id',
					   style:'width:280px; display: block;text-align:center;line-height:22px;',
					   height:20,
       				   fieldLabel : 'radiogroup',
                       columns : 4,
                       vertical :true,
                       items:[
                              {boxLabel:'未评估',inputValue:'2',name:'RadioGroup',checked: true},
         					  {boxLabel:'已评估',inputValue:'1',name:'RadioGroup'},
                              {boxLabel:'停止评估',inputValue:'3',name:'RadioGroup'}],
				        listeners : {
				        	'change' : function(rg, checked){
				        		sqlContent.getEl().dom.readOnly = checked.getGroupValue() == 'yes' ? false : true;
						}}
			    });
	
	//查询条件line2
  	var secondTbar = new Ext.Toolbar({
		items:['科室:', {	
			id : 'foffi_id',
			name : 'foffi',
			width : 90,
			xtype : "textfield",
			enableKeyEvents : true, 
			scope: this,
				listeners: {
			    	'keydown': {key: [10,13], fn: function(o, evt) {
            		var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
							if (keyCode == 13) {
    							Ext.getCmp("fwxcd_id").focus(false,100);
					       }
                 } , scope: this
                 } 
           }
		}, '-', '危险程度:', new Ext.form.ComboBox({
			id : 'fwxcd_id',
			name : 'fwxcd',
			mode : 'local',
			valueField : 'wxcd_id',
			displayField : 'wxcd_desc',
			triggerAction : 'all',
			width : 100,
			enableKeyEvents : true, 
			scope: this,
				listeners: {
			    	'keydown': {key: [10,13], fn: function(o, evt) {
	        		var keyCode = evt.keyCode ? evt.keyCode : evt.charCode;
							if (keyCode == 13) {
								Ext.getCmp("fwxcd_id").collapse(); //关闭下拉框
								Ext.getCmp("fname_id").focus(false,100);
					       }
	             } , scope: this
	             } 
	        },
			store : new Ext.data.SimpleStore( {
				fields : [ 'wxcd_id', 'wxcd_desc' ],
				data : [ [ 1, '低度' ], [ 2, '中度' ], [ 3, '高度' ] ] 
			})
		})] 
	});
	//生成表格
	var grid = new Ext.grid.EditorGridPanel({
		closable : false,
		region : 'center',
		height : 350,
		autoWidth : true,
		cm : colM,
		ds : ds,
		sm : sm,
		tbar:['状态:', radiogroup ],
		listeners : {
			'render' : function(){
				secondTbar.render(this.tbar); 
				firstTbar.render(this.tbar); 
			},
			'rowclick' : function(grid, row) { //双击打开
				var record = grid.getSelectionModel().getSelected();
				if (record) {
					Ext.get("p_name_id").dom.value = record.data.fname;
					Ext.get("p_bihid_id").dom.value = record.data.fbihid;
					Ext.get("fckqk_cy").dom.checked = true;
					Ext.get("p_ckrq_id").dom.value = '2012-09-02';
				}
			}
	 	},
	 	stripeRows : true,
		clicksToEdit:1,
		//defaults:{margins:'20 20 20 20'},
		enableHdMenu : false
	});
	
	var btn_refresh_patient = new Ext.Button({
		text : '刷新',
		iconCls : 'sy-refresh',
		handler : function() {
			ds.removeAll();
			ds.reload();
		}
	});
	
	var btn_save_patient = new Ext.Button({
		text : '保存',
		iconCls : 'sy-sure',
		handler : function() {
			var record = grid.getSelectionModel().getSelected();
			if (record) {
				Ext.Ajax.request({
					url : 'blPatient!updatePatientInfo.do',
					method : 'POST',
					params : {
						"fbihid" : record.data.fbihid,
						"fstate" : record.data.fstate,
						"fwxcd" : record.data.fwxcd
					},
					success : function(response, action) {
						Ext.Msg.alert('', '保存成功！');
						ds.removeAll();
						ds.reload();
					},
					// 提交失败的回调函数
					failure : function() {
						Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');
					}
				});
			}
		}
	});
	
	var btn_table_patient = new Ext.Button({
		text : '评估报表',
		iconCls : 'sy-vcard_edit',
		handler : function() {
			var record_user = grid_user.getSelectionModel().getSelected();
			if (record_user) {
				Ext.Ajax.request({
					url : 'user!clearUserRole.do',
					method : 'POST',
					params : {
						"loginName" : record_user.data.loginName
					},
					success : function(response, action) {
						Ext.Msg.alert('', '成功！');
						ds.removeAll();
						ds.reload();
					},
					// 提交失败的回调函数
					failure : function() {
						Ext.Msg.alert('错误', '服务器出现错误请稍后再试！');
					}
				});
			}
		}
	});
	
	var btn_chart_patient = new Ext.Button({
		text : '图形分析',
		iconCls : 'sy-chart_curve',
		handler : function() {
			
				var chart_detail_window = new Ext.Window({
					
					width : 600,
					height : 350,
					title : '评分变化曲线',
					iconCls : 'sy-win-flag',
					modal : true,
					items : [ new Ext.Panel(
							{
								height : 400,
								html : '<html><head></head><body><iframe name="ifr_jcwh" align="center" id="ifr_jcwh" scrolling="false" frameborder="0" width="100%" height="100%" '
									+ 'src="blsj_qs_show.jsp"></iframe></body></html>'
							})]
				});
				chart_detail_window.show();
			
		}
	});
	/******************************************************************************************************************************/
	/////////////////////////////////////////////////////////////////////////////
	//评估因素
	var ds_pgys = new Ext.data.Store({
		reader : new Ext.data.JsonReader({
			totalProperty : 'totalProperty',
			root : 'root'
		}, Jthtwb),
		idProperty : 'threadid',
		remoteSort : true,
		url : 'pg!queryPgysList.do'
	});
	ds_pgys.load({
		params : {
			start : 0,
			limit : 50
		}
	});

	//定义勾选框，不需要可不必定义
	var sm_pgys = new Ext.grid.CheckboxSelectionModel({
		singleSelect : false
	});
	
	//评分信息
	var score_store = new Ext.data.SimpleStore( {
						fields : [ 'score_id', 'score_desc' ],
						data : [ [ 0, '0' ], [ 1, '1' ], [ 2, '2' ], [ 3, '3' ], [ 4, '4' ], [ 5, '5' ], [ 6, '6' ], [ 7, '7' ], [ 8, '8' ], [ 9, '9' ], [ 10, '10' ] ]});

	//定义列
	var colM_pgys = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(),//增加自动编号，不需要可不必定义
	    {
			header : '评估项目',
			dataIndex : 'fname_pgys',
			width : 60,
			renderer : function(value) {
				if (value == "null") {
					return "";
				} else {
					return value;
				}
			}
		}, {
			header : '相关病情',
			dataIndex : 'fdesc_pgys',
			width : 300,
			renderer : function(value) {
				if (value == "null") {
					return "";
				} else {
					return value;
				}
			}
		}, {
			header : '参考分值',
			dataIndex : 'fscore_pgys',
			width : 60,
			renderer : function(value) {
					if (value == "null") {
						return "";
					} else {
						return value;
					}
				}
		}, {
			header : '评分',
			dataIndex : 'fscore',
			width : 80,
			renderer : function(value, cellmeta, record) {
				if (value == null) {
					return 0;
				} else {
					if(value > record.data.fscore_pgys) {
						Ext.Msg.alert('错误', '<font color=red>'+record.data.fname_pgys+'</font>评分超过了最大参考值！');
						return 0;
					} else {
						return value;
					}
				}
            },
            editor: new Ext.form.ComboBox({
	                mode : 'local',
                    hiddenName : 'fscore',
					hiddenValue : 'score_id',
					id : 'score_combox',
					valueField : 'score_id',
					displayField : 'score_desc',
					triggerAction : 'all',
               		store : score_store
	            })
		} ]);


	var btn_add_pg = new Ext.Button({
		text : '提交',
		iconCls : 'sy-sure',
		handler : function() {
			//校验数据是否填好
			checkPg();
			//循环处理评估因素
			var fpgysStr = "";
			var fscoreStr = "";
			ds_pgys.each(function(record) {
				fpgysStr += record.data.fid_pgys + ",";
				fscoreStr += record.data.fscore + ",";
			});
			fpgysStr = fpgysStr.substring(0, fpgysStr.length - 1);
			fscoreStr = fscoreStr.substring(0, fscoreStr.length - 1);
			
			//循环处理预防措施
			var fyfcsStr = "";
			var fflagStr = "";
			ds_yfcs.each(function(record) {
				fyfcsStr += record.data.fid_yfcs + ",";
				if(Ext.get(record.data.fid_yfcs + "1").dom.checked == true) {
					fflagStr += "1,";
				}
				if(Ext.get(record.data.fid_yfcs + "2").dom.checked == true) {
					fflagStr += "2,";
				}
			});
			fflagStr = fflagStr.substring(0, fflagStr.length - 1);
			fyfcsStr = fyfcsStr.substring(0, fyfcsStr.length - 1);
			
			//不良事件
			var fblsjStr = "";
			if(Ext.get("fblsj_dd").dom.checked == true) {
				fblsjStr += "跌倒,"; 
			} 
			if(Ext.get("fblsj_zc").dom.checked == true) {
				fblsjStr += "坠床,"; 
			}
			if(Ext.get("fblsj_zs").dom.checked == true) {
				fblsjStr += "自伤,"; 
			}
			if(Ext.get("fblsj_tg").dom.checked == true) {
				fblsjStr += "脱管,"; 
			}
			if(Ext.get("other_blsj_id").dom.value != null && Ext.get("other_blsj_id").dom.value != '') {
				fblsjStr += Ext.get("other_blsj_id").dom.value;
			}
			
			Ext.Ajax.request({
				url : 'pg!processPgInfo.do',
				params:{
    	        	'fbihid' : Ext.get("p_bihid_id").dom.value, //住院号
    	        	'fpgrq' : Ext.get("p_date_id").dom.value, //评估日期
    	        	'fnurse' : Ext.get("p_nurse_id").dom.value, //评估护士
    	        	'fblsj' : fblsjStr, //不良事件发生情况
    	        	'fpgysIds' : fpgysStr, //评估项id字符串
    	        	'fscore' : fscoreStr, //评估分字符串
    	        	'fyfcsIds' : fyfcsStr, //预防措施id字符串
    	        	'fflag' : fflagStr //是否采用措施标记字符串
	    	    },
				success : function() {
					ds_pgys.removeAll();
					ds_pgys.reload();
					ds_yfcs.removeAll();
					ds_yfcs.reload();
					Ext.MessageBox.alert('提示', '评估成功！');
				},
				failure : function() {
					Ext.Msg.show({
						title : '错误提示',
						msg : '评估失败！',
						buttons : Ext.Msg.OK,
						icon : Ext.Msg.ERROR
					});
				}
			});
		}
	});

	

	var btn_delete_pg = new Ext.Button({
		text : '清空',
		iconCls : 'sy-cancel',
		handler : function() {
			Ext.get("p_name_id").dom.value = "";
			Ext.get("fckqk_cy").dom.checked = false;
			Ext.get("fckqk_sw").dom.checked = false;
			Ext.get("fckqk_zk").dom.checked = false;
			Ext.get("p_ckrq_id").dom.value = "";
			Ext.get("p_bihid_id").dom.value = "";
			Ext.get("p_date_id").dom.value = "";
			Ext.get("p_nurse_id").dom.value = "";
			Ext.get("fblsj_dd").dom.checked = false; 
			Ext.get("fblsj_zc").dom.checked = false; 
			Ext.get("fblsj_zs").dom.checked = false; 
			Ext.get("fblsj_tg").dom.checked = false;
			Ext.get("other_blsj_id").dom.value = "";
			ds_pgys.removeAll();
			ds_pgys.reload();
			ds_yfcs.removeAll();
			ds_yfcs.reload();
		}
	});
	
	//生成表格
	var grid_pgys = new Ext.grid.EditorGridPanel({
		closable : false,
		region : 'center',
		height : 100,
		autoWidth : true,
		cm : colM_pgys,
		ds : ds_pgys,
		//sm : sm_pgys,
		stripeRows : true,
		clicksToEdit:1,
		enableHdMenu : false
	});
	
	
	
	/////////////////////////////////////////////////////////////////////////////
	//预防措施
	var ds_yfcs = new Ext.data.Store({
		reader : new Ext.data.JsonReader({
			totalProperty : 'totalProperty',
			root : 'root'
		}, Jthtwb),
		idProperty : 'threadid',
		remoteSort : true,
		url : 'pg!queryYfcsList.do'
	});
	ds_yfcs.load({
		params : {
			start : 0,
			limit : 50
		}
	});

	//定义勾选框，不需要可不必定义
	var sm_yfcs = new Ext.grid.CheckboxSelectionModel({
		singleSelect : false
	});
	
	//定义列
	var colM_yfcs = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(),//增加自动编号，不需要可不必定义
	    {
			header : '预防措施',
			dataIndex : 'fdesc_yfcs',
			width : 240,
			renderer : function(value) {
				return '<font color=black id='+value+'>' + value + '</font>';  
			}  
		}, {
			header : '采用措施',
			dataIndex : 'fflag_yfcs',
			width : 200,
			renderer : function(value, cellmeta, record) {
				return "<input id='"+record.data.fid_yfcs+"2' name='"+record.data.fid_yfcs+"' type='radio' value='2' checked='checked'>否</input>&nbsp;&nbsp;"  
		        + "&nbsp;&nbsp;<input id='"+record.data.fid_yfcs+"1' name='"+record.data.fid_yfcs+"' type='radio' value='1' >是</input> ";  
			}
		} ]);
	
	//生成表格
	var grid_yfcs = new Ext.grid.EditorGridPanel({
		closable : false,
		//region : 'north',
		height : 160,
		autoWidth : true,
		stripeRows : true,
		cm : colM_yfcs,
		ds : ds_yfcs,
		//sm : sm_yfcs,
		clicksToEdit:1,
		enableHdMenu : false
	});
	
    var panelmenu = new Ext.Panel({
			region: "west",
			split:true,
            minSize: 175,
            maxSize: 600,
            collapsible: true,
            collapsed: false,
            title : '待评估患者列表',
            margins:'0 0 0 0',
            layout:'fit',
            layoutConfig:{
                animate:true
            },
            tbar : [btn_save_patient, '-', btn_table_patient, '-', btn_chart_patient, '-', btn_refresh_patient, {
				xtype : 'hidden',
				fieldLabel : '角色id2',
				id : 'r_id',
				name : 'fid'
			}],
			items :[grid],
			width:340
	   });	

    //出科情况
    var ckqkCheckGroup = new Ext.form.CheckboxGroup({
        id:'ckqk_id',
	    height:20,
	    fieldLabel : 'radiogroup',
        vertical :true,
        style:'width:240px; display: block;text-align:center;line-height:22px;',
        columns: 4,
        items: [
            {boxLabel: '出院', name: 'fckqk', id: 'fckqk_cy'},
            {boxLabel: '死亡', name: 'fckqk', id: 'fckqk_sw'},
            {boxLabel: '转科', name: 'fckqk', id: 'fckqk_zk'}
        ]
    });
    //不良事件发生情况
    var blsjCheckGroup = new Ext.form.CheckboxGroup({
        id:'blsj_id',
	    height:20,
	    fieldLabel : 'radiogroup',
        vertical :true,
        style:'width:240px; display: block;text-align:center;line-height:22px;',
        columns: 4,
        items: [
            {boxLabel: '跌倒', name: 'fblsj', id: 'fblsj_dd'},
            {boxLabel: '坠床', name: 'fblsj', id: 'fblsj_zc'},
            {boxLabel: '自伤', name: 'fblsj', id: 'fblsj_zs'},
            {boxLabel: '脱管', name: 'fblsj', id: 'fblsj_tg'}
        ]
    });
    
    //按钮工具条
  	var patient_btn_Tbar = new Ext.Toolbar({
		items:[ '姓名:', {	
			id : 'p_name_id',
			name : 'fname_patient',
			width : 70,
			xtype : "textfield"
		}, '-', '住院号:', {	
			id : 'p_bihid_id',
			name : 'fbihid_patient',
			width : 70,
			xtype : "textfield"
		}, '-', '评估日期:', {	
			id : 'p_date_id',
			name : 'fdate_patient',
			width : 100,
			value : new Date(),
			format : 'Y-m-d',
			xtype : "datefield"
		}, '-', '评估护士:', {	
			id : 'p_nurse_id',
			name : 'fnurse_patient',
			width : 70,
			xtype : "textfield"
		} ] 
	});
    //出科情况工具条
  	var ckqk_btn_Tbar = new Ext.Toolbar({
		items:['出科日期:', {	
			id : 'p_ckrq_id',
			name : 'fckrq_patient',
			width : 100,
			format : 'Y-m-d',
			xtype : "datefield"
		},'-', '出科情况:', ckqkCheckGroup ] 
	});
    //不良事件发生情况工具条
  	var blsj_btn_Tbar = new Ext.Toolbar({
		items:[ '不良事件发生情况:', blsjCheckGroup, '-', '其他', {	
			id : 'other_blsj_id',
			name : 'fname_patient',
			width : 140,
			xtype : "textfield"
		} ] 
	});
    
    var panelmenu2 = new Ext.Panel({
		region: "north",
		split:true,
        minSize: 100,
        maxSize: 500,
        height : 300,
        collapsible: false,
        collapsed: false,
        margins:'0 0 0 0',
        layout:'fit',
        layoutConfig:{
            animate:true
        },
        tbar : [ btn_add_pg, '-', btn_delete_pg ],
		listeners : {
			'render' : function(){
				patient_btn_Tbar.render(this.tbar);
				ckqk_btn_Tbar.render(this.tbar); 
				blsj_btn_Tbar.render(this.tbar); 
			}
	 	},
		items :[grid_pgys]
   });	
    
    var panelmenu3 = new Ext.Panel({
		region: "center",
		split:true,
        minSize: 100,
        maxSize: 400,
        collapsible: false,
        collapsed: false,
        margins:'0 0 0 0',
        layout:'fit',
        layoutConfig:{
            animate:true
        },
		items :[grid_yfcs]
   });	

    //提交校验
    function checkPg() {
    	if(Ext.get("p_name_id").dom.value == null || Ext.get("p_name_id").dom.value == '') {
    		Ext.MessageBox.alert('提示', '请填写患者姓名！');
    		return false;
    	}
    	if(Ext.get("p_bihid_id").dom.value == null || Ext.get("p_bihid_id").dom.value == '') {
    		Ext.MessageBox.alert('提示', '请填写患者住院号！');
    		return false;
    	}
    	if(Ext.get("p_date_id").dom.value == null || Ext.get("p_date_id").dom.value == '') {
    		Ext.MessageBox.alert('提示', '请填写评估日期！');
    		return false;
    	}
    	if(Ext.get("p_nurse_id").dom.value == null || Ext.get("p_nurse_id").dom.value == '') {
    		Ext.MessageBox.alert('提示', '请填写评估护士！');
    		return false;
    	}
    	if(Ext.get("p_ckrq_id").dom.value == null || Ext.get("p_ckrq_id").dom.value == '') {
    		Ext.MessageBox.alert('提示', '请填写患者出科日期！');
    		return false;
    	}
    	if(Ext.get("fckqk_cy").dom.checked == false && Ext.get("fckqk_sw").dom.checked == false && Ext.get("fckqk_zk").dom.checked == false) {
    		Ext.MessageBox.alert('提示', '请填写患者出科状况！');
    		return false;
    	}
    	if(Ext.get("fblsj_dd").dom.checked == false && Ext.get("fblsj_zc").dom.checked == false && Ext.get("fblsj_zs").dom.checked == false && Ext.get("fblsj_tg").dom.checked == false && (Ext.get("other_blsj_id").dom.value == null || Ext.get("other_blsj_id").dom.value == '')) {
    		Ext.MessageBox.alert('提示', '请填写患者不良事件发生情况！');
    		return false;
    	}
    	return true;
    }
    
    var panel = new Ext.Panel({
    	region: "center",
		border : true,
		layout : "border",
		title : '不良因素评估',
		margins:'0 5 0 0',
		items : [panelmenu2, panelmenu3]
	});
    
 	new Ext.Viewport( {
		layout : "border",
		items : [panelmenu, panel]
	});
});
</script>

</body>
</html>
